<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.ahp.bean.*" %>
<%@ page import="java.util.*" %>
<%@ include file="../include/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="<%=path %>/js/jquery-1.3.2.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="<%=path%>/style/style_manage.css" type="text/css"></link>
<title>添加新模板</title>
<style type="text/css">
.added{border: 1px solid gray; margin: 1em 1em; padding: 5px 8px;}
.delSpan{cursor: pointer;}
div{line-height: 120%;}
</style>
<%
List<Factor> list = (List)request.getAttribute("list");
%>
<script type="text/javascript">
	function addSecondeFactor(id){
		//alert(id);
		var modID = Number(<%=list.get(0).getModule().getModId()%>);
		//alert(modID);
		var name = $('#'+id+'name').val();
		//alert(name);
		var information = $('#'+id+'information').val();
		//alert(information);
		var pid = $('#'+id+'facid').val();
		//alert(pid);
		$.post("<%=path%>/factor/addFirstFactor.action",{
			"factor.level":"2",
			"factor.pid":pid,
			"factor.module.modId":modID,
			"factor.name":name,
			"factor.information":information,
			d:new Date().getMilliseconds()
		},function(data){
		alert(data);
			if(data == "suc"){
				$("#"+id+"span").append("<span class='added'>"+name+"</span>&nbsp;");
			}
		});
}

</script>
</head>
<body>
<div id="management">
<div style="font-size: 20px;font-weight: bold;"></div>
	<div id="newFactor"></div>
	<br/>
		<table class="table">
			<tr>
				<td>一级因子名</td>
				<td>二级因子名</td>
				<td>二级因子说明</td>
			</tr>
		<%for(int a = 0;a<list.size();a++){
			Factor fac = (Factor)list.get(a);
		%>
			<tr>
				<td><%=fac.getName() %></td>
				<td><input type="hidden" id="<%=fac.getFacId()%>facid" value="<%=fac.getFacId() %>"/>
				<input type="text" id="<%=fac.getFacId() %>name"/></td>
				<td><input type="text" id="<%=fac.getFacId()%>information"/>
				<input type="button" onclick="addSecondeFactor('<%=fac.getFacId() %>');" value="添加"/></td>
			</tr>
			<tr>
				<td id="<%=fac.getFacId() %>span" colspan="3"></td>
			</tr>
		<%} %>
		<tr>
			<td colspan="3" align="center"><input type="button" value="完成"/></td>
		</tr>
		</table>
</div>
</body>
</html>